package al4th.chp1;

import java.util.Scanner;

/**
 * @Author: wanghongfu
 * @Date : Created in 23:16  2017/10/9
 * @Email : 1583505981@qq.com
 * @Description: 欧几里德算法
 */
public class Maxyueshu {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int p=in.nextInt();
        int q=in.nextInt();
        int result=gcd(p,q);
        System.out.println(result);
        in.close();
    }

    public static  int gcd(int p,int q){
        if (q==0){
            return p;
        }
        int r=p%q;
        return  gcd(q,r);
    }
}
